<template>
	<div>
		<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
		<div style="padding: 20px;">
			<!--三率页面(改完字段)-->
			<!--<div style="margin:5px 0px 0px 0px;background-color: #f5f5f5;padding: 20px;">
				<Row >
			        <Col span="24" style="text-align: left;">
						<span style="font-size: 18px;color: #1a1a1a;font-weight: 540;">评价名称：{{excelname}}</span>
					</Col>
				</Row>
				<Row style="margin:15px 0px 0px 0px;color: #666666;">
			        <Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">年级：{{gradeName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">基数：{{baseExamName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">本次：{{thisExamName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">时间：{{createTime}}</span>
					</Col>
				</Row>
			</div>-->
			<Row >
		        <Col span="24" style="text-align: left;margin-top:20px;">
		        	<span>科目筛选：</span>
		        	<RadioGroup  v-model="subjectselect" type="button" @on-change="changeselect">
		        		<Radio v-for="item in subjectlist" :key="item.value" :label="item.value">{{item.label}}</Radio>
				       
				    </RadioGroup>
		        </Col>
		        <Spin size="large" fix v-if="subjectlistshow"></Spin>
		    </Row>
		    <Row >
		        <Col span="24" style="text-align: left;margin-top:20px;">
		        	<span>类型筛选：</span>
		        	<RadioGroup  v-model="scoreTypeSelect" type="button" @on-change="changeselect">
		        		<Radio v-for="item in scoreTypeList" :key="item.value" :label="item.value">{{item.label}}</Radio>
				       
				    </RadioGroup>
		        </Col>
		        <Spin size="large" fix v-if="subjectlistshow"></Spin>
		    </Row>
		    <Row style="margin-top:20px">
		        <Col span="24" style="text-align: right;margin-bottom:10px;">
		        	<!--<Button style="background-color: #4496fc;" size="small" :loading="loading" @click="exportexl">
		        		<span v-if="!loading"><img style="width: 20px;margin-top: 2px;" src="../../../../../../static/img/export.png" alt="" /></span>
				        <span v-else>加载中</span>
		        	</Button>-->
		        </Col>
		    </Row>
			<v-table  v-if='table1' :min-height='500' :is-loading="loadingShow" is-horizontal-resize  is-vertical-resize style="width:100%;" :title-rows="titleRows1" :columns="columns1" :table-data="tableData1" ></v-table>
			<v-table v-if='table2' :min-height='500' :is-loading="loadingShow" is-horizontal-resize  is-vertical-resize style="width:100%;" :title-rows="titleRows2" :columns="columns2" :table-data="tableData2" ></v-table>
			<v-table v-if='table3' :min-height='500' :is-loading="loadingShow" is-horizontal-resize  is-vertical-resize style="width:100%;" :title-rows="titleRows3" :columns="columns3" :table-data="tableData3" ></v-table>
		</div>
	</div>
</template>

<script>
	import api from "@/components/js/Apidomain.js"
	import { getsessionstorage } from '@/components/js/Localstorage'
	
	export default{
		data(){
			return{
//				excelname:"",			//查询的名字
//				gradeName:"",			//查询的年级
//				baseExamName:"",		//查询的基数考试名字
//				thisExamName:"",		//查询的本次考试名字
//				createTime:"",			//查询的评价时间
				
				loadingShow:false,				//表格获取的加载中显示隐藏
				subjectlistshow:false,			//科目选择列表的加载中显示隐藏
				
				loading: false,				//下载模板按钮上的加载中显示隐藏
				
				subjectselect:"",				//选择的科目
				subjectlist: [],
				scoreTypeSelect:"",
				scoreTypeList:[],
				
				table1:false,
                table2:false,
                table3:false,
				//平均分
				titleRows1:[	
						[
							{fields: ['classesNo'], title: '班级', titleAlign: 'center', rowspan: 2,colspan: 1},
	                      	{fields: ['examThisAverage','thisAverage','shouldAverage','gapAverage','goalAverage'], title: '平均分', titleAlign: 'center', rowspan: 1,colspan: 5},
                      	],
                      	[                         
//							{fields: ['classesNo'], title:'班级', titleAlign: 'center'},
		                    {fields: ['examThisAverage'], title: '原始分平均分', titleAlign: 'center',},
		                    {fields: ['thisAverage'], title: '标准分本次平均分', titleAlign: 'center',},
		                    {fields: ['shouldAverage'], title: '标准分应考平均分', titleAlign: 'center',},
		                    {fields: ['gapAverage'], title: '差值', titleAlign: 'center',},
		                    {fields: ['goalAverage'], title: '得分', titleAlign: 'center',},
                		]
                ],
				columns1: [                    
							{field: 'classesNo', title:'班级', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    
		                    {field: 'examThisAverage', title: '原始分平均分', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'thisAverage', title: '本次平均分', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'shouldAverage', title: '应考平均分', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'gapAverage', title: '差额', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'goalAverage', title: '得分', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
                ],
                //优秀率
                titleRows2:[	
						[
							{fields: ['classesNo'], title: '班级', titleAlign: 'center', rowspan: 2,colspan: 1},
	                      	{fields: ['examThisPassRate','thisPassRate','shouldPassRate','gapPassRate','goalPassRate'], title: '及格率', titleAlign: 'center', rowspan: 1,colspan: 5},
                      	],
                      	[                          
		                    {fields: ['examThisPassRate'], title: '原始分及格率', titleAlign: 'center',},
		                    {fields: ['thisPassRate'], title: '标准分本次及格率', titleAlign: 'center',},
		                    {fields: ['shouldPassRate'], title: '标准分应考及格率', titleAlign: 'center',},
		                    {fields: ['gapPassRate'], title: '差额', titleAlign: 'center',},
		                    {fields: ['goalPassRate'], title: '得分', titleAlign: 'center',},
                		]
                ],
				columns2: [                       
							{field: 'classesNo', title:'班级', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'examThisPassRate', title: '原始分及格率', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'thisPassRate', title: '本次及格率', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'shouldPassRate', title: '应考及格率', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'gapPassRate', title: '差额', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'goalPassRate', title: '得分', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
                    	
                ],
				//及格率
                titleRows3:[	
						[
							{fields: ['classesNo'], title: '班级', titleAlign: 'center', rowspan: 2,colspan: 1},
	                      	{fields: ['examThisExcellentRate','thisExcellentRate','shouldExcellentRate','gapExcellentRate','goalExcellentRate'], title: '优秀率', titleAlign: 'center', rowspan: 1,colspan: 5},
                      	],
                      	[                       
		                    {fields: ['examThisExcellentRate'], title: '原始分优秀率', titleAlign: 'center',},
		                    {fields: ['thisExcellentRate'], title: '标准分本次优秀率', titleAlign: 'center',},
		                    {fields: ['shouldExcellentRate'], title: '标准分应考优秀率', titleAlign: 'center',},
		                    {fields: ['gapExcellentRate'], title: '差额', titleAlign: 'center',},
		                    {fields: ['goalExcellentRate'], title: '得分', titleAlign: 'center',}
                    	
                		]
                ],
				columns3: [                  
							{field: 'classesNo', title:'班级', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'examThisExcellentRate', title: '原始分优秀率', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'thisExcellentRate', title: '本次优秀率', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'shouldExcellentRate', title: '应考优秀率', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'gapExcellentRate', title: '差额', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true},
		                    {field: 'goalExcellentRate', title: '得分', width: 101, titleAlign: 'center',columnAlign:'center',isResize:true}
                    	
                ],
                tableData1: [
//                  {"classesNo":"1班","yw":"15","thisAverage":"7","coeAverage":"8","shouldAverage":"6","gapAverage":"1","goalAverage":"3","thisPassRate":"7","coePassRate":"8","shouldPassRate":"6","gapPassRate":"1","goalPassRate":"3","thisExcellentRate":"7","coeExcellentRate":"8","shouldExcellentRate":"6","gapExcellentRate":"1","goalExcellentRate":"3"},
                ],
                tableData2: [
//                  {"classesNo":"1班","yw":"15","thisAverage":"7","coeAverage":"8","shouldAverage":"6","gapAverage":"1","goalAverage":"3","thisPassRate":"7","coePassRate":"8","shouldPassRate":"6","gapPassRate":"1","goalPassRate":"3","thisExcellentRate":"7","coeExcellentRate":"8","shouldExcellentRate":"6","gapExcellentRate":"1","goalExcellentRate":"3"},
                ],
                tableData3: [
//                  {"classesNo":"1班","yw":"15","thisAverage":"7","coeAverage":"8","shouldAverage":"6","gapAverage":"1","goalAverage":"3","thisPassRate":"7","coePassRate":"8","shouldPassRate":"6","gapPassRate":"1","goalPassRate":"3","thisExcellentRate":"7","coeExcellentRate":"8","shouldExcellentRate":"6","gapExcellentRate":"1","goalExcellentRate":"3"},
                ],
                
			}
		},
		created(){
//			this.excelname = getsessionstorage('excelname')
//			this.gradeName = getsessionstorage('gradeName')
//			this.baseExamName = getsessionstorage('baseExamName')
//			this.thisExamName = getsessionstorage('thisExamName')
//			this.createTime = getsessionstorage('createTime')
			this.getsubjectlist()
		},
		computed: {
			
		},
		methods:{
//			test:function(data1,data2,data3){
//				console.log(data1);
//				console.log(data2);
//				console.log(data3);
//			},
			changeselect:function(){
//				//console.log(this.subjectselect)
				this.gettablelist();
			},
			getsubjectlist:function(){
           		this.subjectlistshow = true;
           		let sessionroleid = getsessionstorage('roleid');
           		var self = this;
            	let url = api.apidomain+'/tqes/web/quaPerformance/getSubjectByAd/'+sessionroleid;
            	this.$http.post(url, {}).then(function(response) {
					if(response.data.success == true){
						
//						////console.log(response.data.data)
						self.subjectlist = response.data.data
						if(self.subjectlist.length != 0){
							self.subjectselect = self.subjectlist[0].value;
							self.getScoreTypeSelect();
						}
						
						self.subjectlistshow = false;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            		self.subjectlistshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00156',
							duration: 10,
							closable: true
						});
						self.subjectlistshow = false;
					});
           	},
           	getScoreTypeSelect:function(){
           		var self = this;
            	let url = api.apidomain+'/tqes/web/quaPerformance/getScoreTypeSelect';
            	this.$http.post(url).then(function(response) {
					if(response.data.success == true){
						
//						////console.log(response.data.data)
						self.scoreTypeList = response.data.data
						if(self.scoreTypeList.length != 0){
							self.scoreTypeSelect = self.scoreTypeList[0].value;
							self.gettablelist();
						}
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00283',
							duration: 10,
							closable: true
						});
					});
           	},
			gettablelist:function(){
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId')
				
				var senddata = {
					"subject":this.subjectselect , 		//英文缩写
					"performId":sessionperformId,		//绩效Id
					"roleId":sessionroleid,				//角色Id
					"scoreType":this.scoreTypeSelect			//得分类型
				}
				
				
				if(sessionroleid && sessionperformId){
					this.loadingShow = true;
					var self = this;
	            	let url = api.apidomain+'/tqes/web/quaPerformance/getTreeRateResultsNew';
	            	this.$http.post(url,senddata).then(function(response) {
						if(response.data.success == true){
							self.loadingShow = false;
//		            		console.log(response.data.data)
		            		self.table1 = response.data.data.isAvg
        					self.tableData1 = response.data.data.dataAvg
        					self.table2 = response.data.data.isPass
        					self.tableData2 = response.data.data.dataPass
        					self.table3 = response.data.data.isExcellent
        					self.tableData3 = response.data.data.dataExcellent
//							self.tableData = response.data.data
			            }else if(response.data.success == false){
			            		self.loadingShow = false;
			            		self.$Message.error({
									content: response.data.msg,
									duration: 10,
									closable: true
								});	
			            	}
			            })
						.catch(function(error) {
							self.loadingShow = false;
							self.$Message.error({
								content: '系统发生错误：错误码00284',
								duration: 10,
								closable: true
							});
						});
				}else{
					self.$Message.error({
							content: '系统发生错误：错误码00285',
							duration: 10,
							closable: true
						});
				}
			},
			exportexl:function(){
			
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId');
				let subject = this.subjectselect;
				if(sessionroleid && sessionperformId){
					this.loading = true;
				
					var self = this;
	            	let url = api.apidomain+'/tqes/web/quaPerformance/exportTreeRateResults/'+subject+'/'+sessionperformId+'/'+sessionroleid;
	            	this.$http.post(url).then(function(response) {
						if(response.data.success == true){
	//						////console.log(response.data.data)
							window.location.href = response.data.data;
							self.loading = false;
		            }else if(response.data.success == false){
		            		self.loading = false;
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
		            	}
		            	
					})
					.catch(function(error) {
						self.loading = false;
						self.$Message.error({
							content: '系统发生错误：错误码00159',
							duration: 10,
							closable: true
						});
					});
				}
			}
		}
	}
</script>

<style>
	
</style>